Repository navigation
refactor(mcpx): one shared near-miss matcher — diagnose + launcher migrated (#1904) - #2535
Conversation
…gnose + launcher migrated (#1904)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 39 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Queue worker note (task 3144) — merged Targeted tests on the laptop, after the merge:
Precedent: #2502 merged with the same |
What
Implements #1904: one shared near-miss matcher for mcpx, replacing two divergent definitions.
The same typo was close in one place and not in the other, and search (#1923) was about to add a third definition.
Change
New package
internal/nearmissowns the definition:Normalize— case-folds and removes snake/kebab/camel boundaries, so the spellings of one name are one name.Distance— Damerau-Levenshtein (optimal string alignment) on normalised names; a transposition is one edit.Threshold— length-relative: 1 + len/3, at least 1 (diagnose's existing rule, now shared).Near— the launcher's deliberately narrow test: equal after normalisation, the prefix rule (length > 2), or distance ≤ 1.Nearest— closest candidate within threshold, with deterministic tie-breaking (distance, then lexicographic), so the answer never depends on enumeration order.Migrations:
internal/diagnose'snearest/editDistanceandinternal/launcher'slooksLikePlaceholderhelpers (editDistanceAtMostOne,isTransposition) are deleted in favour of the shared package. Search (#1923) is untouched; the predicate is there for it to consume.One deliberate behaviour change, from the unification itself: diagnose now scores a transposition as one edit (the launcher's long-standing view), so a swapped-letter typo is slightly more likely to earn a suggestion there.
Tests
internal/nearmisspin normalisation, distances (incl. the launcher'sentyrexample), the strictNearpredicate, threshold values, and tie-breaking.go test ./internal/nearmiss/ ./internal/diagnose/ ./internal/launcher/— all pass. CI is the gate for the full suite.Queue task 3144.
Need help on this PR? Tag
@codesmith-botwith what you need.